<?php
/**
 * wap2.0 特卖会 购物流程-修改收货地址
 */

$cache_id = sprintf('%X', crc32(__FILE__));
if (!$smarty->is_cached('flow_address.dwt', $cache_id))
{

	$step = empty($_REQUEST['step']) ? '' : trim($_REQUEST['step']);
	$address_id = empty($_REQUEST['address_id']) ? 0 : $_REQUEST['address_id'];
	$flag = intval(trim($_REQUEST['flag']));
	if ($step == 'use' && $address_id)
	{
		$to_url = wap_getcookie("WAP[back_act]");
		if($flag!='1'){
			wap_setcookie("WAP[address_id]", $address_id);
			wap_setcookie("WAP[back_act]", '');
		}

		if($to_url&&$flag=='1'){
			wap_setcookie("WAP[update_address_id]", $address_id);
			wap_header("Location: ".$to_url);
			exit;
		}else{
			// 返回结算页面
			wap_header("Location: index.php?m=flow&act=checkout");
			exit;
		}
	}


	if(!$flag){
		// 记录用户 跳转链接
		$back_act = 'index.php?m=flow&act=address';
		wap_setcookie("WAP[back_act]", $back_act);
	}

	/* 取得收货地址 */
	$address_list = get_user_address_list($mInterface, $user_token);

	/* OMNITURE 统计  */
	$pageName = '购物袋-收货地址管理';
	include 'omniture/other.php';

	$smarty->assign('address_list', 	$address_list);
	$smarty->assign('flag', 	$flag);
}

$smarty->display('flow_address.dwt');